<?php
class Html
{
	function pager(array $pager)
	{
		//if($pager['p_total'] >1)
		{
			$tmp	=	'<div id="pager">';
			$tmp	.=	($pager['p_offset'] <=1) 
							? '<span>首页</span> | <span>上一页</span>' 
							: "<a href='{$pager['url']}&{$pager['key']}=1'>首页</a>"
							. "<a href='{$pager['url']}&{$pager['key']}=".($pager['p_offset']-1)."'>上一页</a>";
			$tmp	.=	'&nbsp;';
			$tmp	.=	($pager['p_offset'] >= $pager['p_total']) 
							? '<span>下一页</span> | <span>尾页</span>' 
							: "<a href='{$pager['url']}&{$pager['key']}=".($pager['p_offset']+1)."'>下一页</a>"
							. "<a href='{$pager['url']}&{$pager['key']}=".($pager['p_total'])."'>尾页</a>";
			$tmp	.=	"&nbsp;<span>{$pager['r_total']}[{$pager['p_offset']}/{$pager['p_total']}]</span>";
			$tmp	.=	'</div>';
			echo $tmp;
		}
	}
	
	function write($str, $len=null)
	{
		echo $len ? htmlspecialchars(mb_strcut($str, 0, $len)) : htmlspecialchars($str);
	}

}

?>